package whisper.service.auth.aspect;

import org.aspectj.lang.annotation.Aspect;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import whisper.common.exception.authorization.AuthenticationException;
import whisper.common.support.response.WebResponse;

/**
 * Created by JT on 2018/5/31
 */
@ControllerAdvice
@Aspect
public class AuthorizationAspect {

    @ExceptionHandler(value = AuthenticationException.class)
    @ResponseBody
    public WebResponse authenticationExceptionHandler(AuthenticationException authException) {
        return new WebResponse().errer(authException.getMessage());
    }
}
